package com.pi2e.view.activity;



import java.util.ArrayList;
import java.util.List;

import android.content.Intent;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;

import com.pi2e.R;
import com.pi2e.view.adapter.RoomNumAdapter;
import com.pi2e.view.adapter.RoomNumAdapter.OnLinearLayoutClickListener;
import com.pi2e.view.adapter.listener.RecyclerViewClickListener;
import com.pi2e.view.adapter.listener.RecyclerViewClickListener.OnItemClickListener;
import com.pi2e.view.adapter.view.RecycleViewDivider;
import com.pi2e.view.base.BaseActivity;
import com.pi2e.view.common.FootView;
import com.pi2e.view.common.HeaderView;

public class RoomNumActivity extends BaseActivity {
	
	RecyclerView mRecyclerView ;
    List<String> dataList = new ArrayList<>();
    RecycleViewDivider mRdiver  = new RecycleViewDivider() ;
    TextView txt_roomNum ;
	@Override
	public HeaderView initHeaderView() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void setContentView() {
		setContentView(R.layout.activity_roomnum);

	}

	@Override
	public void initView() {
		mRecyclerView = (RecyclerView) findViewById(R.id.recyclerView) ;
		txt_roomNum = (TextView) findViewById(R.id.txt_guide) ;
		mRecyclerView.addItemDecoration(mRdiver);
		initAdapter() ;
	}
	@Override
	public void initFootView() {
		FootView footView = new FootView(RoomNumActivity.this, findViewById(R.id.footId)) ;
		footView.getTex().setText("返 回");
		footView.getTex().setOnClickListener(new  OnClickListener() {
			
			@Override
			public void onClick(View v) {
				finish();
				
			}
		});

	}
	
	private void initAdapter(){
		 dataList.add("1");
		    dataList.add("2");
		    dataList.add("3");
		    dataList.add("4");
		    dataList.add("5");
		    dataList.add("6");
		    dataList.add("7");
		    dataList.add("8");
		    dataList.add("9");	    
		    dataList.add("删除");
		    dataList.add("0");
		    dataList.add("好了");
		    
		  //实例化Adapter并且给RecyclerView设上
		    final RoomNumAdapter adapter = new RoomNumAdapter(dataList,RoomNumActivity.this);
		    mRecyclerView.setAdapter(adapter);
		 
		    // 如果我们想要一个GridView形式的RecyclerView，那么在LayoutManager上我们就要使用GridLayoutManager
		    // 实例化一个GridLayoutManager，列数为3
		    final GridLayoutManager layoutManager = new GridLayoutManager(this, 3);
		 
		    /*//调用以下方法让RecyclerView的第一个条目仅为1列
		    layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
		      @Override
		      public int getSpanSize(int position) {
		        //如果位置是0，那么这个条目将占用SpanCount()这么多的列数，再此也就是3
		        //而如果不是0，则说明不是Header，就占用1列即可
		        return adapter.isHeader(position) ? layoutManager.getSpanCount() : 1;
		      }
		    });*/
		 
		    //把LayoutManager设置给RecyclerView
		    mRecyclerView.setLayoutManager(layoutManager);
		    adapter.setOnLinearLayoutClickListener(new OnLinearLayoutClickListener() {
				
				@Override
				public boolean plusNum(String roomNum) {
					txt_roomNum.setText("您的房间号："+roomNum );
					return false;
				}
				
				@Override
				public void complement() {
					// TODO Auto-generated method stub
					Intent it = new Intent(RoomNumActivity.this,GuideVipActivity.class) ;
					startActivity(it);
				}
				
				@Override
				public boolean addNum(String roomNum) {
					txt_roomNum.setText("您的房间号："+roomNum );
					return false;
				}
			});
		    /*mRecyclerView.addOnItemTouchListener(new RecyclerViewClickListener(RoomNumActivity.this,new OnItemClickListener() {
				
				@Override
				public void onItemLongClick(View view, int position) {
					// TODO Auto-generated method stub
					
				}
				
				@Override
				public void onItemClick(View view, int position) {
					// TODO Auto-generated method stub
					
				}
			} ));*/
	}

}
